﻿package org.summerTree.image
{
	/* 切割位图类，返回一个二维数组*/
	// version 1.0 版本
	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.*;
	public class BitmapSplice 
	{
		 
		public function BitmapSplice()
		{
			
		}
		//进行切割
		public static function Splice(bitmapdata:BitmapData,titleWidth:uint,titleHeight:uint):Array
		{
			var Step:Array=new Array();//存取步数数组
			var iWidth:int=bitmapdata.width /titleWidth;
			var iHeight:int=bitmapdata.height /titleHeight;
			for (var i:uint=0; i < titleHeight; i++)
			{
				var array:Array=new Array();
				for (var j:uint=0; j < titleWidth; j++)
				{
					var tempBMP:BitmapData=new BitmapData(iWidth,iHeight,true,0x00000000);
					tempBMP.copyPixels(bitmapdata,new Rectangle(j * iWidth,i * iHeight,iWidth,iHeight),new Point(0,0));
					array.push(tempBMP);
				}
				Step.push(array);
			}
			bitmapdata.dispose();
			 
          return Step;

		}
	}
}